package controller;

import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.Date;

import model.User;
import model.WorkOutProgram;
import db.DBWorkOut;
import db.DBWorkOutProgram;
import controller.UserController;

public class WorkOutProgramController {

	
	private int currentWorkOutProgramId;
	
	private static WorkOutProgramController workOutProgramController = null;
    /** Making the class private as per the singleton pattern */
    private WorkOutProgramController(){
    
    }
    /** Creating an instance of the class*/
    public static WorkOutProgramController getInstance(){
            if(workOutProgramController == null){
            	workOutProgramController = new WorkOutProgramController();
            }
            return workOutProgramController;
    }
	public ArrayList<WorkOutProgram> findUserWorkOutPrograms(String userId, boolean retriveAssociation){

		DBWorkOutProgram dbProgram = new DBWorkOutProgram();
		ArrayList<WorkOutProgram> allProgram = new ArrayList<WorkOutProgram>();
		allProgram = dbProgram.findUserWorkOutPrograms(userId, retriveAssociation);
		return allProgram;	

	}
	
	   public void addToProgram(int workOutProgramId,int workOutId){
		   
	   }
	
	public int createWorkOutProgram(String dateString, boolean isCompleted){
		DBWorkOutProgram dbProgram = new DBWorkOutProgram(); 
		String userId = UserController.getInstance().getCurrentUser();
		
		int workOutProgramId = dbProgram.insertWorkOutProgram(isCompleted,dateString,userId);
		
		return workOutProgramId;
	}

	public ResultSet getUserWorkOutPrograms(String userId) {
		DBWorkOutProgram dbprogram = new DBWorkOutProgram();
		ResultSet rs = dbprogram.getUserWorkOutPrograms(userId);
		return rs;
	}
	public int getCurrentWorkOutProgramId() {
		return currentWorkOutProgramId;
	}
	public void setCurrentWorkOutProgramId(int currentWorkOutProgramId) {
		this.currentWorkOutProgramId = currentWorkOutProgramId;
	}
	
}
